<xsl:stylesheet version="1.0"
	xmlns:date="http://exslt.org/dates-and-times"
  xmlns:ebe="http://cks/ebemethods"
	xmlns:string="http://exslt.org/strings"
	xmlns:ms="urn:schemas-microsoft-com:xslt"
  xmlns:dt="urn:schemas-microsoft-com:datatypes"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  exclude-result-prefixes="date ebe string">

  <xsl:param name="IsBlogOwner" />
  <xsl:param name="RelativeUrl" />
  <xsl:param name="Language" />
  <xsl:param name="ShortDatePattern" />
  <xsl:param name="IsTechnoratiEnabled" />

  <xsl:output omit-xml-declaration="yes" />

<xsl:template match="/">
	<div id="content" class="posts">	
		<!-- <xmp><xsl:copy-of select="."/></xmp> -->
		<xsl:apply-templates select="rows/row"/>
	</div>
</xsl:template>

<xsl:template match="row">
		<xsl:variable name="publishedDate" select="date:parseDate(PublishedDate, 'yyyy-MM-dd HH:mm:ss')"/>

		<h3>
			<xsl:value-of select="Title"/>
      &#160;<xsl:value-of select="ebe:ExportPDF('themes/Summer/images/exportPDF.gif', ID)" disable-output-escaping="yes" />
		</h3>
	
		<h4>
			<xsl:value-of select="date:format-date($publishedDate, 'MMMM d, yyyy')"/>
			&#183;
      <xsl:value-of select="ebe:res('PostedBy')"/>&#160;<xsl:value-of select="substring-after(Author,'#')"/>	
			<br/>
			<a href="#comments" title="Comments">
        <xsl:value-of select="NumComments"/>&#160;
        <xsl:choose>
          <xsl:when test="NumComments = 1">
            <xsl:value-of select="ebe:res('Comment')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="ebe:res('Comments')"/>
          </xsl:otherwise>
        </xsl:choose>
      </a>
				&#183;
      <a href="{$RelativeUrl}/_layouts/cks/ebe/Trackback.aspx?ID={ID}" rel="trackback">
        <xsl:value-of select="ebe:res('TrackbackUrl')"/>
      </a>
		</h4>
		
		<xsl:if test="$IsBlogOwner = 'True'">
			<a href="/{substring-after(FileDirRef,'#')}/EditPost.aspx?ID={ID}">
				[<xsl:value-of select="ebe:res('EditPost')"/>]
			</a>
		</xsl:if>

		<div class="entry">
			<p>
				<xsl:value-of select="Body" disable-output-escaping="yes"/>
			</p>
		</div>
		
		<p class="tagged">
			<strong><xsl:value-of select="ebe:res('Tags')"/>:</strong>
			<xsl:call-template name="TagLoop"><xsl:with-param name="tag" select="Categories" /></xsl:call-template>
      <xsl:if test="$IsTechnoratiEnabled = 'True'">
        <br/>
        <strong><xsl:value-of select="ebe:res('TechnoratiTags')"/>:</strong>
        <xsl:for-each select="string:split(CategoriesAsText, ';')">
          <a href="http://technorati.com/tag/{.}" rel="tag">
            <xsl:value-of select="."/>
          </a>
          <xsl:if test="position() != last()"> &#183;</xsl:if>
        </xsl:for-each>
      </xsl:if>

      <a href="http://del.icio.us/post?url={ebe:createAbsolutePostUrl(PublishedDate, BlogTitleForUrl)}&amp;title={Title}" title="Add to del.icio.us"><img src="{$RelativeUrl}/themes/summer/images/delicious.png" border="0"/></a>
				<a href="http://digg.com/submit?phase=2&amp;url={ebe:createAbsolutePostUrl(PublishedDate, BlogTitleForUrl)}" title="Digg it"><img src="{$RelativeUrl}/themes/summer/images/digg.png" border="0"/></a>
				<a href="http://technorati.com/cosmos/search.html?url={ebe:createAbsolutePostUrl(PublishedDate, BlogTitleForUrl)}" title="Add to Technorati"><img src="{$RelativeUrl}/themes/summer/images/technorati.png" border="0"/></a>
				<a href="http://www.facebook.com/share.php?u={ebe:createAbsolutePostUrl(PublishedDate, BlogTitleForUrl)}" title="Add to Facebook"><img src="{$RelativeUrl}/themes/summer/images/facebook.gif" border="0"/></a>
				<a href="http://reddit.com/submit?url={ebe:createAbsolutePostUrl(PublishedDate, BlogTitleForUrl)}&amp;title={Title}" title="Add to Reddit"><img src="{$RelativeUrl}/themes/summer/images/reddit.png" border="0"/></a>
		</p>
<br/>
<br/>
</xsl:template>

<!-- a recursive template to replace character delimiters in tags -->
<xsl:template name="TagLoop">
	<xsl:param name="tag" />
	<xsl:variable name="tag_after" select="substring-after($tag, ';#')" />
	
	<xsl:choose>
		<!-- display next tag and call template recursivly -->
		<xsl:when test="contains($tag_after, ';#')">
			<xsl:variable name="tag_before" select="substring-before($tag_after, ';#')" />
			<a href="{ebe:createTagUrl($tag_before)}" title="View all posts in {$tag_before}" rel="category tag"><xsl:value-of select="$tag_before" /></a> &#183;
			<xsl:call-template name="TagLoop">
				<xsl:with-param name="tag" select="substring-after($tag_after, ';#')" />
			</xsl:call-template>
		</xsl:when>
		<!-- display last tag -->
		<xsl:otherwise>
			<a href="{ebe:createTagUrl($tag_after)}" title="View all posts in {$tag_after}" rel="category tag"><xsl:value-of select="$tag_after"/></a>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

</xsl:stylesheet>
